<template> <!-- 发货记录-->
	<view class="wrap">
		<view class="search cu-bar">
			<u-search  v-model="barCode" :focus="focus" @custom="search" @search="search" placeholder="扫一扫"  :show-action="false"></u-search>
			<view class="action" @click="toScan">
				<text class="cuIcon-scan" style="font-size: 56rpx;"></text>
			</view>
		</view>
		<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
			<view  class='tolView' v-for="(item, index) in list" :key="index" @click="addcg(item)">
				<view class="text" style="position: relative;"><text class="text-bold">【{{index+1}}】</text> <text class="text-bold">存货编码：{{item.basInv.cinvcode}}</text><text></text></view><br/>
				<view style="margin-bottom: 5px;"><text class="">存货代码：</text>{{item.basInv.cinvaddcode}}</view>
				<view style="margin-bottom: 5px;"><text class="">存货名称：</text>{{item.basInv.cinvname}}</view>
				<view style="margin-bottom: 5px;"><text class="">批次：</text>{{item.cbatch}}</view>
				<view style="margin-bottom: 5px;"><text class="">仓库：</text>{{item.cwhcode}}</view>
				<view style="margin-bottom: 5px;"><text class="">上架数量：</text>{{item.iqty}}</view>
				<view style="margin-bottom: 5px;"><text class="">实集号：</text>{{item.retrace}}({{item.sum}})</view>
			</view>
			<view class="loadmore" >
				<u-loadmore :status="loadStatus"></u-loadmore>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				focus: true,
				flag:false,
				barCode:'',
				query: {
					status: '0',
					pageNo: 1,
					pageSize: 20,
					barcode:'',
				},
				list:[],
				loadStatus: 'loadmore',
			}
		},
		onShow() {
			this.search();
		},
		onLoad() {},
		methods: {
			addcg(item){
				uni.navigateTo({
				  url: '/pages/asd/index/cgsj/add?data='+JSON.stringify(item)
				})
			},
			toScan(){
				var _this = this;
				uni.scanCode({ 
					onlyFromCamera: true,
					success: function(res) {
						this.barCode = res.result;
						this.search();
					}.bind(this)
				});
			},
			loadMore() {
				this.loadStatus = "loading";
				setTimeout(() => {
					this.query.pageNo += 1;
					this.loadList("add");
				}, 100);
			},
			search(value) {
				this.list = [];
				this.query.barcode = this.barCode;
				this.query.pageNo = 1;
				this.loadList();
			},
			loadList(type) {
				this.$u.api.asdApi.findTmSl(this.query).then(res => {
					this.barCode = '';
					if (res.data.length < 20 || res.data.length == 0){
						this.loadStatus = "nomore";
					}
					var data = res.data;
					if(type=="add"){
						for(var i=0;i<data.length;i++){
							this.list.push(data[i])
						}
					}else{
						this.list = data;	
					}
				})
			},
			
		}
	}
</script>

<style>
.tableclass{
	border-left: 1px solid rgb(228, 231, 237);
	border-top: 1px solid rgb(228, 231, 237);
	background-color: rgb(255, 255, 255);
	width: 100%;box-sizing: border-box;
}
.thclass {
	text-align: center;
	padding: 5px 3px;
	border-bottom: 1px solid rgb(228, 231, 237);
	border-right: 1px solid rgb(228, 231, 237);
	flex-direction: column;
	flex: 1;
	justify-content: center;
	font-size: 14px;
	color: #303133;
	font-weight: bold;
	background-color: #f5f6f8;
}
.trclass {
	height: 52px;
}
.tdclass {
	padding: 5px 3px;
	border-bottom: 1px solid rgb(228, 231, 237);
	border-right: 1px solid rgb(228, 231, 237);
	flex-direction: column;
	flex: 1;
	justify-content: center;
	font-size: 14px;
	color: #505256;
	align-self: stretch;
	box-sizing: border-box;
	height: 100%;
}
.box .item{
	margin: 0 0px 0px;
}
.tui-line-cell {
		width: 100%;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}
	.tui-title {
		line-height: 32rpx;
		min-width: 120rpx;
		flex-shrink: 0;
	}
	
	.tui-input {
		font-size: 32rpx;
		color: #333;
		padding-left: 20rpx;
		flex: 1;
		overflow: visible;
	}
.footer {
	position: fixed;
	left: 0;
	bottom: 20px;
	width: 100%;
	
}
.edit{
	position: absolute;
	right: 195rpx;
	top: 0;
	margin-right: 0;
}
.add{
	position: absolute;
	right: 130rpx;
	top: 0;
	margin-right: 0;
}
.upload {
	position: absolute;
	right: 65rpx;
	top: 0;
	margin-right: 0;
}
.rights {
	position: absolute;
	/* display: inline-block; */
	right: 0;
	top: 0;
	margin-right: 0;
	/* width: 100%; */
	
}
.addPlan{
	position: absolute;
	right: 60rpx;
	top: -40rpx;
}

.tolView{
	background-color: #fff; 
	margin: 10px;
	padding: 10px; 
	border-radius:10px ;
}
</style>
